<template>
	<view class="">
		<view class="uni-form-item uni-column">
			<view class="title">姓名</view>
			<input class="uni-input" v-model="FormData.name" focus placeholder="请输入姓名" />
		</view>
		<view class="uni-form-item uni-column">
			<view class="title">客户账号/手机号</view>
			<input class="uni-input" v-model="FormData.account" placeholder="请输入客户手机号" />
		</view>
		<view class="uni-form-item uni-column">
			<view class="title">初始密码</view>
			<input class="uni-input" v-model="FormData.pwd" placeholder="请输入初始密码" />
		</view>
		<view class="uni-padding-wrap uni-common-mt">
			<button type="primary" @click="add">提交</button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				FormData: {
					name: '',
					account: '',
					pwd: '',
					tjId: '',
				}
			}
		},
		onLoad: function (option) { //option为object类型，会序列化上个页面传递的参数
				console.log(option.tjId); //打印出上个页面传递的参数。
				this.FormData.tjId = option.tjId
		},
		methods: {
			add() {
				if (this.FormData.account == "") {
					uni.showToast({
						icon: 'none',
						title: "请输入手机号",
						duration: 2000,
					})
					return
				}
				
				if (this.FormData.pwd == "") {
					uni.showToast({
						icon: 'none',
						title: "请输入初始密码",
						duration: 2000,
					})
					return
				}
				let params = this.FormData
				console.log(params)
				this.$api.zhuce(params).then((res) => {
					if(res.success) {
					uni.showToast({
						icon: 'success',
						title: "成功",
						duration: 2000,
						success: () => {
							window.location.href = "http://jhyyyl.longshunha.com:61/html"; 
						}
					})
					}else {
						uni.showToast({
							icon: 'none',
							title: res.msg,
							duration: 2000
						});
					}
				}).catch((err) => {
					console.log('request fail', err);
				})
			}
		}
	}
</script>

<style>
	
</style>
